<template>
  <div class="intr">
    <header>
      <i class="el-icon-notebook-1"></i>
      战队介绍
    </header>
    <div class="intr_con">
      <ul class="tab-tilte">
        <li @click="cure = 0" :class="{ active: cure == 0 }">东部</li>
        <li @click="cure = 1" :class="{ active: cure == 1 }">西部</li>
      </ul>
      <div class="tab-content">
        <div v-show="cure == 0" class="comm_con2">
          <div class="introduction-detail">
            <div class="team-tab team-tab1">
              <span class="team-btn team-prev team-btn-active" @click="toLeft"></span>
              <span href="javascript:;" class="team-btn team-next" @click="toRight"></span>
              <div class="team-inner">
                <div class="team-name-con">
                  <div class="team-item" v-for="item in eastteam" :key="item.id" :data-id="item.id" @click="chooseteam1(item.id)" :class="{ teamactive: team == item.id }">
                    <div class="team-item-img"><img :src="item.logo" alt="" /></div>
                    <div class="team-item-word">{{ item.name }}</div>
                  </div>
                </div>
              </div>
              <div class="team-maincon" v-for="cons in eastteam" :key="cons.id" v-show="cons.id == team" @click="team2 = cons.id">
                <div class="team-main-list team-main-list1">
                  <div class="team-main-tbox">
                    <div class="team-big-img">
                      <img :src="cons.logo" alt="" />
                    </div>
                    <div class="team-main-present">
                      <div class="team-present-title clearFixed">
                        <h4>{{ cons.name }}</h4>
                      </div>
                      <div class="team-present-word">
                        {{ cons.descr }}
                      </div>
                    </div>
                  </div>
                  <div class="team-main-bbox">
                    <div class="active-duty">战队现役选手</div>
                    <div class="duty-members">
                      <a href="javascript:;" class="duty-btn duty-prev duty-active" @click="MemLeft"></a>
                      <a href="javascript:;" class="duty-btn duty-next" @click="MemRight"></a>
                      <div class="duty-inner">
                        <div class="duty-item-con">
                          <div class="duty-item" v-for="item2 in cons.memlist" :key="item2.id">
                            <img :src="item2.icon" alt="" />
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-show="cure == 1" class="comm_con2">
          <div class="introduction-detail">
            <div class="team-tab team-tab1">
              <a href="javascript:;" class="team-btn team-prev team-btn-active" @click="toLeft"></a>
              <a href="javascript:;" class="team-btn team-next" @click="toRight"></a>
              <div class="team-inner">
                <div class="team-name-con" ref="teambanner">
                  <div class="team-item" v-for="item in westteam" :key="item.id" :data-id="item.id" @click="chooseteam(item.id)" :class="{ teamactive2: team4 == item.id }">
                    <div class="team-item-img"><img :src="item.logo" alt="" /></div>
                    <div class="team-item-word">{{ item.name }}</div>
                  </div>
                </div>
              </div>
              <div class="team-maincon" v-for="cons2 in westteam" :key="cons2.id" v-show="cons2.id == team4" @click="team4 = cons2.id">
                <div class="team-main-list team-main-list1">
                  <div class="team-main-tbox">
                    <div class="team-big-img">
                      <img :src="cons2.logo" alt="" />
                    </div>
                    <div class="team-main-present">
                      <div class="team-present-title clearFixed">
                        <h4>{{ cons2.name }}</h4>
                      </div>
                      <div class="team-present-word">
                        {{ cons2.descr }}
                      </div>
                    </div>
                  </div>
                  <div class="team-main-bbox">
                    <div class="active-duty">战队现役选手</div>
                    <div class="duty-members">
                      <a href="javascript:;" class="duty-btn duty-prev duty-active" @click="MemLeft"></a>
                      <a href="javascript:;" class="duty-btn duty-next" @click="MemRight"></a>
                      <div class="duty-inner">
                        <div class="duty-item-con">
                          <div class="duty-item" v-for="item2 in cons2.memlist" :key="item2.id">
                            <img :src="item2.icon" alt="" />
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data: () => ({
    cure: '',
    teaminfo: [],
    team: 81,
    team2: 81,
    team3: 783,
    team4: 783,
    beginplace: 0,
    Memplace: 0
  }),
  created () {
    this.getteaminfo()
  },
  methods: {
    async getteaminfo () {
      const { data } = await this.$axios.get('/match/teamdata')
      this.teaminfo = data.teamlist
    },
    toLeft (e) {
      var ele = e.currentTarget.parentNode.childNodes[2].childNodes[0]
      this.beginplace += 131
      if (this.beginplace > 0) {
        this.beginplace = 0
      }
      ele.style.left = this.beginplace + 'px'
      // console.dir(e.currentTarget.parentNode.childNodes[2])
    },
    toRight (e) {
      var ele = e.currentTarget.parentNode.childNodes[2].childNodes[0]
      let father = e.currentTarget.parentNode.childNodes[2].clientWidth
      this.beginplace -= 131
      if (this.beginplace < father - ele.clientWidth) this.beginplace = father - ele.clientWidth
      // console.log(father - ele.clientWidth)
      ele.style.left = this.beginplace + 'px'
    },
    chooseteam (index) {
      this.team4 = index
    },
    chooseteam1 (index) {
      this.team = index
    },
    teamPeople (singleteam) {
      return singleteam.filter(item => {
        return item.id === this.team
      })
    },
    MemLeft (e) {
      var ele = e.currentTarget.parentNode.childNodes[2].childNodes[0]
      this.Memplace += 101
      if (this.Memplace > 0) {
        this.Memplace = 0
      }
      ele.style.left = this.Memplace + 'px'
      // console.dir(e.currentTarget.parentNode.childNodes[2])
    },
    MemRight (e) {
      var ele = e.currentTarget.parentNode.childNodes[2].childNodes[0]
      let father = e.currentTarget.parentNode.childNodes[2].clientWidth
      this.Memplace -= 101
      if (this.Memplace < father - ele.clientWidth) this.Memplace = father - ele.clientWidth
      console.log(father - ele.clientWidth)
      ele.style.left = this.Memplace + 'px'
    }
  },
  computed: {
    eastteam: function () {
      return this.teaminfo.filter(function (item) {
        return item.zone === '1'
      })
    },
    westteam: function () {
      return this.teaminfo.filter(function (item) {
        return item.zone === '2'
      })
    }
  },
  mounted () {}
}
</script>
<style lang="less" scoped>
li {
  list-style: none;
}
.clearFixed:after {
  content: '';
  display: block;
  clear: both;
}
.intr {
  width: 820px;
  header {
    height: 40px;
    font-size: 22px;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
  }
  .intr_con {
    .tab-tilte {
      display: flex;
      padding-left: 0;
      li {
        width: 50%;
        height: 36px;
        background-color: #ddd;
        text-align: center;
        line-height: 36px;
      }
      .active {
        color: #fff;
        background-color: #f3c258;
      }
    }
    .tab-content {
      .introduction-detail {
        width: 820px;
        margin: 10px 0;
        // opacity: 0;
        .team-tab {
          width: 100%;
          .team-next,
          .team-prev {
            display: block;
            margin: 25px 0;
            width: 18px;
            height: 60px;
            border-radius: 4px;
          }
          .team-prev {
            float: left;
            background: url(//game.gtimg.cn/images/yxzj/match/center2018/images/team-prev.png) no-repeat #8b8b8b;
            background-position: 4px;
          }
          .team-btn-active {
            background-color: #f3c258;
          }
          .team-next {
            float: right;
            background: url(//game.gtimg.cn/images/yxzj/match/center2018/images/team-next.png) no-repeat #8b8b8b;
            background-position: 6px;
          }
          .team-inner {
            // width: 780px;
            height: 127px;
            margin: 0 auto;
            overflow: hidden;
            position: relative;
            .team-name-con {
              position: absolute;
              white-space:nowrap;
              transition: left 0.3s ease-out;
              .team-item {
                width: 113px;
                height: 113px;
                // float: left;
                display: inline-block;
                background: #f4f5f4;
                margin: 0 8px;
                cursor: pointer;
                .team-item-img {
                  width: 113px;
                  height: 85px;
                  display: flex;
                  text-align: center;
                  img {
                    max-width: 75px;
                    align-self: center;
                    text-align: center;
                    margin: 0 auto;
                  }
                }
                .team-item-word {
                  text-align: center;
                  font-size: 12px;
                }
              }
              .teamactive,
              .teamactive2 {
                width: 113px;
                height: 119px;
                background: url(//game.gtimg.cn/images/yxzj/match/center2018/images/team-active.png) no-repeat;
              }
              .team-item:first-child {
                margin-left: 10px;
              }
            }
          }
          .team-maincon {
            width: 820px;
            height: 280px;
            .team-main-list {
              background: #eee;
              .team-main-tbox {
                padding: 10px 35px;
                height: 150px;
                .team-big-img {
                  width: 130px;
                  height: 150px;
                  float: left;
                  display: flex;
                  margin-top: 15px;
                  img {
                    max-width: 100%;
                    align-self: center;
                    text-align: center;
                    margin: 0 auto;
                  }
                }
                .team-main-present {
                  float: right;
                  width: 580px;
                  .team-present-title {
                    margin-top: 10px;
                    height: 45px;
                  }
                  h4 {
                    display: block;
                    font-size: 30px;
                    float: left;
                    margin: 0;
                  }
                  .team-present-word {
                    color: #363636;
                    line-height: 28px;
                    font-size: 14px;
                  }
                }
              }
              .team-main-bbox {
                padding: 10px 35px 30px;
                height: 80px;
                .active-duty {
                  width: 130px;
                  float: left;
                  font-size: 16px;
                  line-height: 85px;
                  text-align: center;
                }
                .duty-members {
                  width: 560px;
                  float: right;
                  margin-right: 20px;
                  .duty-next,
                  .duty-prev {
                    display: block;
                    margin: 24px 0;
                    width: 18px;
                    height: 36px;
                    border-radius: 4px;
                  }
                  .duty-prev {
                    float: left;
                    background: url(//game.gtimg.cn/images/yxzj/match/center2018/images/duty-prev.png) no-repeat;
                    background-position: 0 -36px;
                  }
                  .duty-active {
                    background-position: 0 0;
                  }
                  .duty-next {
                    float: right;
                    background: url(//game.gtimg.cn/images/yxzj/match/center2018/images/duty-next.png) no-repeat;
                    background-position: 0 -36px;
                  }
                  .duty-inner {
                    width: 505px;
                    height: 89px;
                    margin: 0 auto;
                    overflow: hidden;
                    position: relative;
                    .duty-item-con {
                      position: absolute;
                      height: 89px;
                      white-space: nowrap;
                      transition: left 0.3s ease-out;
                      .duty-item {
                        width: 85px;
                        height: 85px;
                        background: #f3c258;
                        border-radius: 50%;
                        border: 2px solid #f3c258;
                        margin: 0 6px;
                        cursor: pointer;
                        overflow: hidden;
                        display: inline-block;
                        img {
                          max-width: 100%;
                          align-self: center;
                          text-align: center;
                          margin: 0 auto;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      .introcons {
        opacity: 1;
      }
    }
  }
}
</style>
